<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common_include_top.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<body>
<style>
textarea
{
width:100%;
height:100%;
}
</style>



<div id="content">
<!-- Main Content -->
<div align="center" class="page_title">
  栏目 &nbsp; ${dataForm.instance.name}
</div>


<div style="border-color:#70a3f2; border-style:solid; 
	border-width:1px 0px 0px 0px; width:100%; height:1px;">
</div>
<div>

<div >
<div  style="float:left;font-weight:bold;">
 本栏目内书籍列表
</div>


<div align="right" style="display:block;padding-right:5px;">
共${tagElementList.nrOfElements}个结果
</div>
<div style="clear:both;">
</div>
</div>
<form:form id="tagElementForm" name="tagElementForm" modelAttribute="dataForm" method="POST">
<table class="table2"  width="100%" border="0" cellspacing="0" >
  <tr class="bgtitle" style="height:20px;">
  <td>
  	<input name="selectAll" type="checkbox" 
  		onClick="checkAll(document.getElementById('tagElementForm'), 'keys',this)" value="all"/>
  	<span>全选</span></td>
  <td>标题</td>
  <td  class="end">分类</td>
  </tr>
  <c:forEach var="item" items="${tagElementList.pageList}">

  <tr align="center">
	  <td><form:checkbox path="keys" value="${item.id}"/></td>
	  <td><a href="<c:url value="/viewBook.do?itemId=${item.id}"/>">${item.title}</a></td>
	  <td><c:if test="${item.category != null}">${item.category}</c:if></td>
  </tr>
  </c:forEach>

  </table>
  <input type="hidden" id ="actionType" name="actionType"/>
  <form:hidden path="instance.id"/>
</form:form>
</div>
<div>

<table width="100%" height="auto">
  <tr align="right">
  <td style="vertical-align:middle;" align="middle">
  <script type="text/javascript">
	<!--
	function untagBook() {
		document.getElementById('actionType').value="removeTag";
		document.tagElementForm.submit();
		return true;
	}
	//-->
</script>

  <input type="submit" onclick="untagBook();" class="button_blue" value="移除所选书籍"/>
  &nbsp;
  </td>
  <td style="vertical-align:middle;" align="right" colspan="4">
    <div style="margin-top:10px; float:right;">
    	<form method="GET" name="tagNumberForm">
    	<input type="hidden" name="itemId" value="${dataForm.instance.id}"/>
		<c:if test="${!tagElementList.firstPage}">
		    <a href="?itemId=${dataForm.instance.id}&pageTagNumber=0"><font color="blue"><B>
		    &lt;&lt; 第一页
		    </B></font></a>
		  </c:if>
		  
		<c:if test="${!tagElementList.firstPage}">
		    <a href="?itemId=${dataForm.instance.id}&pageTagNumber=${tagElementList.page - 1}"><font color="blue"><B>
		    &lt; 上一页</B></font></a>
		</c:if>
		<span>
		<font color="black"><B>&nbsp;
		  	共
		  	</B></font>
		 
		 ${tagElementList.pageCount}
		<font color="black"><B>页
	  		&nbsp;</B></font>
	  	</span>
		<font color="black"><B>&nbsp;
		  	第
		  	</B></font>

		
          <select name="pageTagNumber"/>
            <c:forEach var="i" begin="0" end="${tagElementList.lastLinkedPage}">
          	<option <c:if test="${i == tagElementList.page}">selected</c:if> value="${i}">
          	<c:out value="${i + 1}"/>
          	</option>
          	</c:forEach>
          </select>
		
	  	
	  	<font color="black"><B>页
	  		&nbsp;</B></font>
	  	</span>

		  <c:if test="${!tagElementList.lastPage}">
		    <a href="?itemId=${dataForm.instance.id}&pageTagNumber=${tagElementList.page + 1}"><font color="blue"><B>
		   	 下一页 &gt;</B></font></a>
		  </c:if>
		  <c:if test="${!tagElementList.lastPage}">
		    <a href="?itemId=${dataForm.instance.id}&pageTag=last"><font color="blue"><B>
		    末页 &gt;&gt;</B></font></a>
		  </c:if>

	  </form>
	  </div>
    </td>
	<td align="right">
		<a href="#" onclick="document.tagNumberForm.submit();return true;">
			<div class="link_button_blue" style="padding-top:5px;">
			Go</div>
		</a>
	</td>
  </tr>
</table>
</div>

<div class="clear"></div>


</div>
<div style="border-color:#70a3f2; border-style:solid; 
	border-width:1px 0px 0px 0px; width:100%; height:1px;"></div>

<div align="center" class="page_title">

</div>

<div >

<div style="float:left; font-weight:bold;">
可选书籍列表 &nbsp;
</div>
<div  style="float:left; padding-left:10px;">
 
<form:form action="viewBookTag.do" method="GET">
<c:if test="${not empty searchedKeywords}">
<input id="keywords" name="keywords" 
		value=
		"${searchedKeywords}"
		onfocus="clear_input_p(this,'#e5fff3');"
    	onblur="setbg_p(this,'white', '请输入关键字');"
    	onchange="check_input_p(this, 'white');"/>
</c:if>
<c:if test="${empty searchedKeywords}">
<input id="keywords" name="keywords" 
		value=
		"请输入关键字"
		onfocus="clear_input_p(this,'#e5fff3');"
    	onblur="setbg_p(this,'white', '请输入关键字');"
    	onchange="check_input_p(this, 'white');"/>
</c:if>
<input type="submit" class="button_blue" value="查找书籍"/>

<input type="hidden" name="itemId" value="${dataForm.instance.id}"/>
</form:form>
</div>

<div align="right" style="display:block;padding-right:5px;">
共${tagDataList.nrOfElements}个结果
</div>
<div style="clear:both;">
</div>
</div>

<c:if test="${!empty operationMsg}">
  	<div align="left"><b><font color="RED"><c:url value="${operationMsg}"/></font></b></div>
</c:if>
<form:form id="pageDataForm" name="pageDataForm" modelAttribute="dataForm" method="POST">
<table class="table2"  width="100%" border="0" cellspacing="0" >
  <tr class="bgtitle" style="height:20px;">
  <td>
  	<input name="selectAll" type="checkbox" 
  		onClick="checkAll(document.getElementById('pageDataForm'), 'keys',this)" value="all"/>
  	<span>全选</span></td>
  <td>标题</td>
  <td class="end">分类</td>
  </tr>
  <c:forEach var="item" items="${tagDataList.pageList}">

  <tr align="center">
	  <td><form:checkbox path="keys" value="${item.id}"/></td>
	  <td><a href="<c:url value="/viewBook.do?itemId=${item.id}"/>">${item.title}</a></td>
	  <td><c:if test="${item.category != null}">${item.category.name}</c:if></td>
  </tr>
  </c:forEach>

  </table>
  <input type="hidden" id ="actionType1" name="actionType"/>
  <form:hidden path="instance.id"/>
</form:form>

<!-- Page Control Buttons -->
 <table width="100%" height="auto">
  <tr align="right">
  <td style="vertical-align:middle;" align="middle">
  <script type="text/javascript">
	<!--
	function tagBook() {
		
		document.getElementById('actionType1').value="addTag";
		document.pageDataForm.submit();
		return true;
	}

	//-->
</script>
  <input type="submit" onclick="tagBook();" class="button_blue" value="添加所选书籍"/>
  &nbsp;
  </td>
  <td style="vertical-align:middle;" align="right" colspan="4">
    <div style="margin-top:10px; float:right;">
    	<form method="GET" name="pageNumberForm">
    	<input type="hidden" name="itemId" value="${dataForm.instance.id}"/>
		<c:if test="${!tagDataList.firstPage}">
		    <a href="?itemId=${dataForm.instance.id}&pageNumber=0"><font color="blue"><B>
		    &lt;&lt; 第一页
		    </B></font></a>
		  </c:if>
		  
		<c:if test="${!tagDataList.firstPage}">
		    <a href="?itemId=${dataForm.instance.id}&page=previous&pageNumber=${tagDataList.page - 1}"><font color="blue"><B>
		    &lt; 上一页</B></font></a>
		</c:if>
		<span>
		<font color="black"><B>&nbsp;
		  	共
		  	</B></font>
		 
		 ${tagDataList.pageCount}
		<font color="black"><B>页
	  		&nbsp;</B></font>
	  	</span>
		<font color="black"><B>&nbsp;
		  	第
		  	</B></font>

		
          <select name="pageNumber"/>
            <c:forEach var="i" begin="0" end="${tagDataList.lastLinkedPage}">
          	<option <c:if test="${i == tagDataList.page}">selected</c:if> value="${i}">
          	<c:out value="${i + 1}"/>
          	</option>
          	</c:forEach>
          </select>
		
	  	
	  	<font color="black"><B>页
	  		&nbsp;</B></font>
	  	</span>

		  <c:if test="${!tagDataList.lastPage}">
		    <a href="?itemId=${dataForm.instance.id}&page=next&pageNumber=${tagDataList.page + 1}"><font color="blue"><B>
		   	 下一页 &gt;</B></font></a>
		  </c:if>
		  <c:if test="${!tagDataList.lastPage}">
		    <a href="?itemId=${dataForm.instance.id}&page=last"><font color="blue"><B>
		    末页 &gt;&gt;</B></font></a>
		  </c:if>

	  </form>
	  </div>
    </td>
	<td align="right">
		<a href="#" onclick="document.pageNumberForm.submit();return true;">
			<div class="link_button_blue" style="padding-top:5px;">
			Go</div>
		</a>
	</td>
  </tr>
</table>

</div>
<!--End of Main Content -->


<!-- body bottom -->
<%@ include file="/WEB-INF/jsp/common_include_bottom.jsp"%>